package com.stgy.lease.web.api.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.stgy.lease.common.result.Result;
import com.stgy.lease.web.api.dto.BaseSearchDto;
import com.stgy.lease.web.api.dto.RoomInfoSearchDto;
import com.stgy.lease.web.api.service.RoomInfoService;
import com.stgy.lease.web.api.vo.RoomDetailVo;
import com.stgy.lease.web.api.vo.RoomItemVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName:RoomController
 * Package:com.stgy.lease.web.api.controller
 * Description:
 *
 * @Author:helei
 * @Create:2024/9/6 - 10:35
 */
@RestController
@RequestMapping("/app/room")
@Tag(name = "房间模块")
public class RoomController {

    @Autowired
    private RoomInfoService roomInfoService;

    //http://localhost:8888/app/room/pageItem?current=1&size=10
    @Operation(summary = "条件分页查询房间列表")
    @GetMapping("/pageItem")
    public Result<Page<RoomItemVo>> pageItem(RoomInfoSearchDto searchDto) {
        return Result.ok(roomInfoService.pageItem(searchDto));
    }

    @Operation(summary = "根据id查询房间详情")
    @GetMapping("/getDetailById")
    public Result<RoomDetailVo> getDetailById(@RequestParam Long id) {
        return Result.ok(roomInfoService.getDetailById(id));
    }

    //http://localhost:8888/app/room/pageItemByApartmentId?
    // id=1830404678916026369&current=1&size=10 GET
    @Operation(summary = "根据公寓id分页查询房间列表")
    @GetMapping("/pageItemByApartmentId")
    public Result<Page<RoomItemVo>> pageItemByApartmentId(BaseSearchDto baseSearchDto){
        return Result.ok(roomInfoService.pageItemByApartmentId(baseSearchDto));
    }
}
